/**
 * create by young (young2f@outlook.com) on 2020/12/4
 */
'use strict';
const model = require('../base/tModelBase');
const _ = require('lodash');
module.exports = app => {
  const mongoose = app.mongoose;
  const schema = mongoose.Schema;
  const connect = app.mongooseDB.get('pmcBus');
  const json = {
    date: { type: Date, _type: 'date', title: '日期', required: true , enableArea: [

      ]},
    code: { type: String, _type: 'code', title: '编码', required: true , enableArea: [

      ]},
    division: {
      type: String, _type: 'select', title: '寄件单位', required: true, options: [
        '镇江新蓝化工科技有限公司',
        '句容经济开发区生涌化工原料经营部',
        '江苏迈蔚环境科技有限公司',
        '江苏景开环境工程有限公司',
        '南京开广化工有限公司',
        '句容安澜环保材料有限公司',
        '阿迈斯工业产品(苏州)有限公司',
      ], enableArea: [
"table"
      ]
    },
    salesman: { type: String, _type: 'string', title: '业务员', required: true , enableArea: [
        "table"
      ]},
    addr: { type: String, _type: 'string', title: '收件地址', required: true, enableArea: [
        "table"
      ] },
    receiver: { type: String, _type: 'string', title: '收件单位', enableArea: [
        "table"
      ] },
    contacts: { type: String, _type: 'string', title: '联系人', enableArea: [
        "table"
      ] },
    contactsPhone: { type: String, _type: 'string', title: '联系电话', enableArea: [
        "table"
      ] },
    prods: {
      type: Array, _type: 'array', title: '物品详情',
      cols: [
        { type: String, _type: 'string', title: '品名', key: 'name', required: true },
        { type: String, _type: 'string', title: '规格', key: 'spec' },
        { type: String, _type: 'string', title: '型号', key: '_model' },
        { type: String, _type: 'string', title: '类别', key: 'type' },
        { type: String, _type: 'string', title: '数量/kg', key: 'count' },
        { type: String, _type: 'string', title: '其它信息', key: 'other' },
      ], enableArea: [

      ]
    },
    origin: {
      type: String, _type: 'select', title: '始发地', options: [
        '句容', '库房'
      ], enableArea: [
        "table"
      ]
    },
    express: { type: String, _type: 'string', title: '快递公司', enableArea: [
        "table"
      ] },
    trackingNumber: { type: String, _type: 'string', title: '快递单号', enableArea: [
        "table"
      ] },
    fileList: { type: Array, _type: 'fileList', title: '图片列表' },
  };
  const _model = _.cloneDeep(model);
  _.assign(_model, json);
  const _schema = new schema(
    _model,
    { timestamps: { createdAt: 'createdTs', updatedAt: 'updatedTs' } }
  );
  return connect.model('DicSample', _schema);
};
